package com.help.help.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.help.help.entity.CateEntity;
import com.help.help.service.CateService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author 小🌤
 * @email 1578442339@qq.com
 * @date 2021-01-07 15:41:11
 */
@RestController
@RequestMapping("/help/cate")
public class CateController {
    @Autowired
    private CateService cateService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = cateService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 获取全部
     */
    @GetMapping("/findAll")
  public R findAll(){
        return R.ok().put("data",cateService.list());
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		CateEntity cate = cateService.getById(id);

        return R.ok().put("cate", cate);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody CateEntity cate){
		cateService.save(cate);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody CateEntity cate){
		cateService.updateById(cate);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		cateService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
